{extend name='admin@main'}

{block name="button"}
<!--
{if auth("add_holiday")}
<button data-open='{:url("add_holiday")}' data-title="我要休假" class='layui-btn layui-btn-sm layui-btn-primary'>我要休假</button>
{/if}
-->


{if auth("state")}
<button data-action='{:url("state")}' data-rule="id#{key}" data-csrf="{:systoken('state')}" data-confirm="确定要强制办结吗？" class='layui-btn layui-btn-sm layui-btn-primary'>强制办结</button>
{/if}

{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='holiday/index_search'}
    <table class="layui-table margin-top-10" lay-skin="switch" id="table">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>
            <th class='text-left nowrap'>ID</th>
            <th class='text-left nowrap'>姓名</th>


            <th>可休天数</th>         
            <th>已休天数</th>
            <th>未休天数</th>
            <th>休假类型</th>
            <th>起始时间</th>
            <th>结束时间</th>
            <th>休假天数</th>
            <th width="20%">备注</th>
            <th width="8%">状态</th>

            <th class='text-left nowrap'></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
			<td class='text-left nowrap'>{$vo.id|default=''}</td>
            <td class='text-left nowrap'><a href="/admin.html#{:url('uncheckholiday')}?name={$vo.name}&leixing=">{$vo.name|default='-'}</a></td>
            
			
            <td>{$vo.yingxiu}</td>
            <td>{$vo.yixiu}</td>
            <td>{$vo.weixiu}</td>
            <td>{$vo.leixing_text}</td>
            <td>{$vo.startdate}</td>
            <td>{$vo.enddate}</td>
            <td>{$vo.days}</td>
            <th>{$vo.remark}</th>

            <td>
                {:html_entity_decode($vo.admin_status_text)}
            </td>
            <td class='text-left nowrap'>
                {if $vo.status == 0 }
                    {if auth("edit_holiday") }
                    <a data-dbclick class="layui-btn layui-btn-sm layui-btn-warm" data-title="审 批" data-open='{:url("edit_holiday")}?id={$vo.id}'>审 批</a>
					<a class="layui-btn layui-btn-sm " data-title="查 看" data-open='{:url("viewdoc")}?id={$vo.id}' >查 看</a>
                    {/if}
                {elseif $vo.status == 1}
				<a class="layui-btn layui-btn-sm" data-title="打 印" href='{:url("printdoc")}?id={$vo.id}' target="new">打 印</a>
                {else}
				<a class="layui-btn layui-btn-sm " data-title="查 看" data-open='{:url("viewdoc")}?id={$vo.id}' >查 看</a>
                {/if}
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
<script src="__ROOT__/static/plugs/tablesum.js"></script>

<script type="text/javascript">



    function heji(table_id, lie, val_id) {
        //合计 --xpp
        //table_id： 要统计的table 的id值 
        //lie：要统计哪一列 
        //val_id：将合计值写入哪
        totalSou = 0;
        $("#"+table_id+" tbody tr").each(function () {
			var id =$('#table tr td:nth-child(10)').text();  
            var num = $($(this).find("td")[lie]).text();
			//console.log(id);
            totalSou += getNumValue(num);
        });
        $("#" + val_id).text(Number(totalSou.toFixed(4)));
    }
    function getNumValue(num) {
        if (!isNaN(num)) {
            num = parseFloat(num);
        }
        else {
            num = 0;
        }
        return num;
    }
	
$(function(){
	heji('table', '9', 'val_id');
});
</script>


<script type="text/javascript">
  // $('table').tableSum({'sumText':'total'})
</script>
{/block}
